/// <summary>
/// This class handles requests from the API and 
/// sends them to the C# application via delegates.
/// <summary>

#pragma managed

namespace API
{
	public ref class InterProcess : System::MarshalByRefObject
	{
	public:
		InterProcess(void);

		delegate bool DelegateB_S(System::Object ^ manager, System::String ^ url);
		delegate bool DelegateB_SS(System::Object ^ manager, System::String ^ repository, System::String ^ application);
		delegate bool DelegateB_SSS(System::Object ^ manager, System::String ^ repository, System::String ^ application, System::String ^ component);
		delegate int  DelegateI_SSS(System::Object ^ manager, System::String ^ repository, System::String ^ application, System::String ^ component);

	internal:
		DelegateB_SS  ^ m_ApplicationIsInstalled;
		DelegateB_SSS ^ m_ComponentIsInstalled;
		DelegateB_SSS ^ m_ComponentInstall;
		DelegateB_SSS ^ m_ComponentUpdate;
		DelegateB_SSS ^ m_ComponentUninstall;
		DelegateB_SSS ^ m_VersionIsLatest;
		DelegateB_S   ^ m_MiscellaneousCallURL;
		DelegateB_S   ^ m_AuthorizedCallURL;
		System::Object ^ m_Manager;

	public:
		bool ApplicationIsInstalled(System::String ^ repository, System::String ^ application);
		bool ComponentIsInstalled(System::String ^ repository, System::String ^ application, System::String ^ component);
		bool ComponentInstall(System::String ^ repository, System::String ^ application, System::String ^ component);
		bool ComponentUpdate(System::String ^ repository, System::String ^ application, System::String ^ component);
		bool ComponentUninstall(System::String ^ repository, System::String ^ application, System::String ^ component);
		bool VersionIsLatest(System::String ^ repository, System::String ^ application, System::String ^ component);
		bool MiscellaneousCallURL(System::String ^ url);
		bool AuthorizedCallURL(System::String ^ url);

		void SetCalls(
			DelegateB_SS  ^ applicationisinstalled,
			DelegateB_SSS ^ componentisinstalled,
			DelegateB_SSS ^ componentinstall,
			DelegateB_SSS ^ componentupdate,
			DelegateB_SSS ^ componentuninstall,
			DelegateB_SSS ^ versionislatest,
			DelegateB_S   ^ miscellaneouscallurl,
			DelegateB_S   ^ authorizedcallurl
			);
		void SetManager(
			System::Object ^ manager
			);

		System::String ^ GetHash();

		virtual System::Object ^ InitializeLifetimeService() override;
	};
}
